﻿<Window x:Class="LogicCircuit.DialogUsage"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:lc="clr-namespace:LogicCircuit"
	xmlns:properties="clr-namespace:LogicCircuit.Properties"
	WindowStartupLocation="CenterOwner"
	Title="{x:Static properties:Resources.TitleCircuitUsage}"
	Style="{StaticResource DialogWindow}"
>
	<Window.Resources>
		<DataTemplate x:Key="NotUsed">
			<TextBlock TextWrapping="Wrap" Text="{x:Static properties:Resources.MessageNotUsed}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
		</DataTemplate>

		<DataTemplate x:Key="IsUsed">
			<lc:AutoGrid ColumnWidths="*">
				<TextBlock TextWrapping="Wrap" Text="{x:Static properties:Resources.MessageUsageNote}" Margin="5"/>
				<ListBox ItemsSource="{Binding}" Margin="3" MouseDoubleClick="ListBoxMouseDoubleClick">
					<ListBox.ItemTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Path=Name}"/>
						</DataTemplate>
					</ListBox.ItemTemplate>
				</ListBox>
			</lc:AutoGrid>
		</DataTemplate>
	</Window.Resources>

	<lc:AutoGrid>
		<Label Content="{x:Static properties:Resources.TitleName}"/>
		<TextBlock Text="{Binding Path=LogicalCircuit.Name}" VerticalAlignment="Center"/>

		<ContentControl Grid.ColumnSpan="2" lc:AutoGrid.RowHeight="*" Content="{Binding Path=Usage}">
			<ContentControl.Style>
				<Style TargetType="ContentControl">
					<Setter Property="ContentTemplate" Value="{StaticResource IsUsed}"/>
					<Style.Triggers>
						<DataTrigger Binding="{Binding Path=Usage.Count}" Value="0">
							<Setter Property="ContentTemplate" Value="{StaticResource NotUsed}"/>
						</DataTrigger>
					</Style.Triggers>
				</Style>
			</ContentControl.Style>
		</ContentControl>

		<StackPanel Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Right">
			<Button Content="{x:Static properties:Resources.TitleOK}" IsDefault="True" IsCancel="True"/>
		</StackPanel>
	</lc:AutoGrid>
</Window>
